<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Gadget Preview</title>
</head>
<body>
<div style="width:300px; padding:5px; border:1px solid #ccc; overflow:auto;">
<?php
//Gadget view from xml file
//Use utf8 encode
//Use preg no xmlparse

error_reporting(E_ALL);

$dir = "../gadgets";
if(isset($_GET['c'])) {
	$file = "/" . $_GET['c'] . "/" . $_GET['c'] . ".xml";
} else {
	$file = "/example/example.xml";
}

if(!is_file($dir . $file)) {
	print("$file not find!");
}

$str = file_get_contents($dir.$file);
$str = str_replace("\n","", $str);
$p = "/<!\[CDATA\[(.*)\]\]>/i";

if (preg_match($p, $str, $a)) {
	//print_r($a);
	echo $a[1];
} else {
	echo "Can't match!";
}
?>
</div>
</body>
</html>

